
#pragma once;

#include <WinDef.h>

#include <DXGI.h>
#include <D3D10_1.h>
#include <D3DX11.h>
#include <D3DX10math.h>

class Vector4
{
public:
    Vector4();
    Vector4(const Vector4& other);
    Vector4(FLOAT x, FLOAT y, FLOAT z, FLOAT w = 0);
    Vector4& operator = (const Vector4& other);
    ~Vector4();

	// Static constructors.
	//-----------------------------------------------
	static Vector4 CreateVector(FLOAT x, FLOAT y, FLOAT z);
	static Vector4 CreatePoint(FLOAT x, FLOAT y, FLOAT z);

	// Getters & Setters.
	//-----------------------------------------------
	BOOL IsNull() const;
	BOOL IsVector() const;
	BOOL IsPoint() const;

	FLOAT Length() const;
	FLOAT LengthSquared() const;

	FLOAT GetX() const;
	VOID SetX(FLOAT x);

	FLOAT GetY() const;
	VOID SetY(FLOAT y);

	FLOAT GetZ() const;
	VOID SetZ(FLOAT z);

	FLOAT GetW() const;
	VOID SetW(FLOAT w);

	// Operations.
	//-----------------------------------------------
	Vector4 Interpolate(const Vector4& other, FLOAT u) const;
	Vector4 Normalize() const;

	// Operators.
	//-----------------------------------------------
	BOOL FuzzyCompare(const Vector4& other) const;
    BOOL operator == (const Vector4& other) const;
    BOOL operator != (const Vector4& other) const;

    Vector4 Add(const Vector4& other) const;
    Vector4 operator + (const Vector4& other) const;
    Vector4& operator += (const Vector4& other);

    Vector4 Sub(const Vector4& other) const;
    Vector4 operator - (const Vector4& other) const;
    Vector4& operator -= (const Vector4& other);

    Vector4 Mul(FLOAT factor) const;
    Vector4& operator *= (FLOAT factor);
	Vector4& operator - ();

	Vector4 Div(FLOAT factor) const;
	Vector4& operator /= (FLOAT factor);

    FLOAT Dot(const Vector4& other) const;
    Vector4 Cross(const Vector4& other) const;

	// Casting operators.
	//-----------------------------------------------
	operator D3DXVECTOR2() const;
	operator D3DXVECTOR3() const;
	operator D3DXVECTOR4() const;

private:
	// Attributes.
	//-----------------------------------------------
    FLOAT x, y, z, w;	// If w == 0 it's a vector, otherwise it's a point.
};

Vector4 operator * (const Vector4& vector, FLOAT factor);
Vector4 operator * (FLOAT factor, const Vector4& vector);

